package com.example.springai.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatHistoryMapper{


    /**
     * 保存会话记录
     *
     * @param type   会话类型
     * @param chatId 会话ID
     */
    @Insert("insert into chat_history (type, chat_id) values (#{type}, #{chatId})")
    void save(String type, String chatId);


    /**
     * 删除会话记录
     *
     * @param type   会话类型
     * @param chatId 会话ID
     */
    @Delete("delete from chat_history where type = #{typr} and chat_id = #{chatId}")
    void delete(String type, String chatId);


    /**
     * 获取指定类型的会话记录
     *
     * @param type 会话类型
     * @return 会话记录
     */
    @Select("select chat_history.chat_id from chat_history where type = #{type}")
    List<String> getChatIds(String type);

}
